Use awk to sum a column of numbers

cat count.txt | awk '{ sum+=$1} END {print sum}'

# or

numsum count.txt

Reference: http://www.commandlinefu.com/commands/view/1497/using-awk-to-sumcount-a-column-of-numbers.

Homepage
Comments

Hide Comments